#!/usr/bin/env python3
"""
JH子系统虚拟数据生成脚本
用于快速创建测试用的职位数据
"""

import asyncio
import sys
import os

# 添加项目根目录到路径
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

async def main():
    """主函数"""
    print("🎯 JH子系统虚拟数据生成器")
    print("="*50)
    
    try:
        from src.jh_subsystem.job_data_service import job_data_service
        
        print("📊 初始化数据库...")
        await job_data_service.initialize_database()
        
        print("📈 获取统计信息...")
        stats = await job_data_service.get_overview_statistics()
        
        if stats:
            print("\n✅ 虚拟数据生成完成！")
            print(f"📊 数据统计:")
            print(f"  总职位数: {stats['total_jobs']}")
            print(f"  平均薪资: {stats['avg_salary']:.0f}元/月")
            print(f"  薪资范围: {stats['min_salary']:.0f} - {stats['max_salary']:.0f}元/月")
            print(f"  远程职位: {stats['remote_jobs']} ({stats['remote_percentage']}%)")
            
            print(f"\n🔥 热门技能 (Top 5):")
            for i, skill in enumerate(stats['top_skills'][:5], 1):
                print(f"  {i}. {skill['skill']}: {skill['job_count']}个职位, 平均薪资{skill['avg_salary']:.0f}元")
            
            print(f"\n🏙️ 热门城市 (Top 5):")
            for i, location in enumerate(stats['top_locations'][:5], 1):
                print(f"  {i}. {location['location']}: {location['job_count']}个职位, 平均薪资{location['avg_salary']:.0f}元")
        else:
            print("❌ 无法获取统计信息")
        
        print("\n🚀 现在可以启动系统测试AI聊天功能了！")
        print("运行命令: python scripts/start_jh_chat.py")
        
    except Exception as e:
        print(f"❌ 生成虚拟数据失败: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("\n\n👋 数据生成中断") 